﻿// JavaScript Document
$(document).ready(function () {
    delete window.confirm;
    delete window.alert;

    $(".chosen").chosen({ no_results_text: "No results matched" });

    $(function () {
        $("#Released").datepicker({
            yearRange: "1888:" + (new Date).getFullYear(),
            dateFormat: "dd/mm/yy",
            changeMonth: true,
            changeYear: true
        });
    });

    $('[rel=popover]').popover({ placement: 'left' });
    $('.bottom[rel=tooltip]').tooltip({ placement: 'bottom' });
    $('[rel=tooltip]').tooltip();

    $("a.movie-image").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'elastic'
    });

    $('.carousel').carousel({ interval: 7500, pause: "false" });

    $('#carousel .active.item > img').animate({
        top: '+=130%'
    }, 7500);

    $('#carousel')
        .bind('slide', function () {
            $(this).find('.item:not(.active) > img').stop(true, true).css("top", "-150%");
        })
        .bind('slid', function () {
            $(this).find('.active.item > img').animate({
                top: '+=130%'
            }, 7500);
        });

    $('.modal').modal({ show: false });

    $.fn.raty.defaults.path = 'http://' + document.location.host + '/Content/img/';
    $.fn.raty.defaults.starOn = 'glyphicons_halflings_005_star.png';
    $.fn.raty.defaults.starOff = 'glyphicons_halflings_006_star_empty.png';
    $.fn.raty.defaults.starHalf = 'glyphicons_halflings_007_star_half.png';

    $('#star').raty({
        half: true
    });

    $('.star-rating').raty({
        readOnly: true,
        score: function () {
            return $(this).attr('data-rating').replace(",", ".") / 2;
        },
        hints: ['', '', '', '', '']
    });

    $('.star-rating[data-rating=0]').css("visibility", "hidden");

    $('time.timeago').timeago();

    $('#add-genres').click(function () {
        $('#add-genres-box').slideDown();
        $(this).hide();
    });
    $('#add-languages').click(function () {
        $('#add-languages-box').slideDown();
        $(this).hide();
    });
});